package com.db.dao;

import java.sql.Connection;
import java.util.List;

import com.db.bean.Work;
import com.db.bean.Workclass;

import util.BaseDAO;

/**
* @author 作者:秋哲    E-mail:2810201146@qq.com:
* @version 创建时间：2020年5月21日 下午9:41:26
* @description: 
*/
public class WorkDAOImpl extends BaseDAO<Work> implements WorkDAO {
	@Override
	public int insert(Work work_obj) {
		String sql = "insert into work_work values(?,?,?,?)";
		int update = update(sql, null,work_obj.getMsg(),work_obj.getWorkClass_id(),work_obj.getTitle());
		return update;
	}
	@Override
	public int deleteById( int work_id) {
		String sql = "delete from work_work where id = ?";
		int update = update(sql, work_id);
		return update;
	}
	@Override
	public int update(Work work_obj) {
		String sql = "update work_work set `msg`=?,`workClass_id`=?,`title`=? where id = ?";
		int update = update(sql, work_obj.getMsg(),work_obj.getWorkClass_id(),work_obj.getTitle(),work_obj.getId());
		return update;
	}
	@Override
	public List<Work> getAll( int workClass_id) {
		String sql = "select * from work_work where workClass_id = ?";
		List<Work>  obj = queryList(sql, workClass_id);
		return obj;
	}
	@Override
	public Work getById(int work_id) {
		String sql = "select * from work_work where id = ?";
		Work query = query(sql, work_id);
		return query;
	}
	@Override
	public Work getByTitle(int workGroup_id,String workClass_title) {
		String sql = "select *  from work_work where title = ? and workClass_id = ?";
		Work query = query(sql, workClass_title,workGroup_id);
		return query;
	}
}
